{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-page">
	<form class="layui-form gg-form-bar border-x border-t">
		<div class="layui-input-inline" style="width:120px">
			<select name="cate_id">
				<option value="">试卷分类</option>
				{volist name = ":get_base_data('paper_cate')" id="vo"}
				<option value="{$vo.id}">{$vo.title}</option>
				{/volist}
			</select>
		</div>
		<div class="layui-input-inline" style="width:120px">
			<select name="types">
				<option value="">试卷类型</option>
				<option value="1">培训考试</option>
				<option value="2">日常考试</option>
			</select>
		</div>
		<div class="layui-input-inline" style="width:300px">
			<input type="text" name="keywords" placeholder="关键字" class="layui-input" autocomplete="off" />
		</div>
		<div class="layui-input-inline" style="width:150px">
			<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="table-search"><i class="layui-icon layui-icon-search mr-1"></i>搜索</button>
			<button type="reset" class="layui-btn layui-btn-reset" lay-filter="table-reset">清空</button>
		</div>
	</form>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
  	<h3>我的考试</h3>
  </div>
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
	<script>
	const moduleInit = ['tool','tablePlus'];
	function gouguInit() {
		var table = layui.tablePlus, tool = layui.tool, form = layui.form, dropdown = layui.dropdown;
		layui.pageTable = table.render({
			elem: '#test'
			,toolbar: '#toolbarDemo'
			,title:'我的考试'
			,url: "/exam/exam/datalist"
			,page: true
			,cellMinWidth: 80
			,height: 'full-114'
			,cols: [[
				{field:'id',width:80, title: 'ID号', align:'center'}
				,{field:'cate',width:120, title: '所属分类', align:'center'}
				,{field:'title',title: '试卷名称',minWidth:200}
				,{field:'types',width:80, title: '考试性质', align:'center',templet: function(d){
					var html1='<span class="green">培训考试</span>';
					var html2='<span class="blue">日常考试</span>';
					if(d.types==1){
						return html1;
					}
					else{
						return html2;
					}
				}}
				,{field:'train',title: '关联培训计划',minWidth:200}
				,{field:'start_time',width:260, title: '考试开放周期', align:'center',templet: function(d){
					return d.start_time +' 至 '+ d.end_time;
				}}
				,{field:'duration',width:100, title: '考试时长', align:'center',templet: function(d){
					return d.hour +'小时'+ d.minute +'分 ';
				}}
				,{field:'total_score',width:80, title: '试卷总分', align:'center'}
				,{field:'good_score',width:90, title: '优秀分数线', align:'center'}
				,{field:'pass_score',width:90, title: '及格分数线', align:'center'}
				,{field:'status', title: '状态',width:80,align:'center',templet: function(d){
					var html1='<span class="green">已考试</span>';
					var html2='<span class="red">未考试</span>';
					if(d.record_count==0){
						return html2;
					}
					else{
						return html1;
					}
				}}
				,{width:90,fixed:'right', title: '操作', align:'center',templet: function(d){
					var html='';
					var btn='<a class="layui-btn layui-btn-xs" lay-event="view">去考试</a>';
					var btn1='<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="record">考试记录</a>';
					if(d.record_count==0){
						return btn;
					}
					else{
						return btn1;
					}
				}}
			]]
		});
		
		table.on('tool(test)',function (obj) {
			if(obj.event === 'view'){					
				tool.side("/exam/exam/exam?id="+obj.data.id);
			}
			if(obj.event === 'record'){					
				tool.side("/exam/exam/view?id="+obj.data.id);
			}
			return false;
		});
	}
	</script>
{/block}
<!-- /脚本 -->